var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("UIManager"),
    c = e("ShopViewUI"),
    d = e("GetZsViewUI"),
    h = cc._decorator,
    _ = h.ccclass,
    u = h.property,
    p = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.active_num = null),
                (t.task_name = null),
                (t.task_info = null),
                (t.task_schedule_bar = null),
                (t.schedule_num = null),
                (t.go_btn_node = null),
                (t.get_award_node = null),
                (t.task_award_node = null),
                (t.get_over_node = null),
                (t.task_index = 0),
                (t.game_task_info = null),
                (t.uiManager = null),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.initView = function () {
                this.uiManager = cc.find("UIManager").getComponent(l.default);
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(a.default.SEND_UPDATE_TASK_INFO, this.updateTaskInfo, this);
            }),
            (t.prototype.showTaskInfo = function (e) {
                (this.task_index = e), (this.node.scale = 1);
                var t = s.default.task_info[this.task_index];
                (this.game_task_info = t),
                    (this.active_num.string = t.active + ""),
                    (this.task_name.string = t.name),
                    (this.task_info.string = t.info),
                    (this.task_award_node.children[0].active = 0 == t.award_type),
                    (this.task_award_node.children[1].active = 1 == t.award_type),
                    (this.task_award_node.children[2].getComponent(cc.Label).string = t.award + "");
                var o = i.GlobalParams.PlayerTaskInfo.value.schedule[e],
                    n = s.default.task_over_info[e];
                -1 != o
                    ? ((o = o > n ? n : o),
                      (this.schedule_num.string = o + "/" + n),
                      (this.task_schedule_bar.width = (660 * o) / n),
                      (this.get_award_node.active = o >= n),
                      (this.go_btn_node.active = o < n),
                      (this.node.zIndex = this.get_award_node.active ? e : 20 + e),
                      (this.get_over_node.active = !1))
                    : ((this.get_award_node.active = !1),
                      (this.go_btn_node.active = !1),
                      (this.node.zIndex = 40 + e),
                      (this.task_schedule_bar.width = 660),
                      (this.get_over_node.active = !0)),
                    this.get_award_node.on("click", this.getTaskAward, this),
                    this.go_btn_node.on("click", this.goTaskInfo, this);
            }),
            (t.prototype.updateTaskInfo = function () {
                this.showTaskInfo(this.task_index);
            }),
            (t.prototype.getTaskAward = function () {
                var e = this;
                r.default.ButtonSound();
                var t = i.GlobalParams.PlayerTaskInfo.value;
                (t.schedule[this.task_index] = -1),
                    (i.GlobalParams.PlayerTaskInfo.value = t),
                    this.uiManager.addCoinAni(this.game_task_info.award, this.game_task_info.award_type),
                    this.emitEvent(a.default.SEND_PLAYER_GET_TASK_AWARD),
                    cc
                        .tween(this.node)
                        .to(0.5, {scale: 0})
                        .call(function () {
                            e.showTaskInfo(e.task_index), e.emitEvent(a.default.SEND_UPDATE_TASK_INFO);
                        })
                        .start();
            }),
            (t.prototype.goTaskInfo = function () {
                r.default.ButtonSound(),
                    1 == this.game_task_info.id
                        ? this.uiManager.showPopup("SigninViewUI")
                        : 2 == this.game_task_info.id
                        ? this.uiManager.showPopup("LuckyBoxViewUI")
                        : -1 != [3, 4, 8, 9].indexOf(this.game_task_info.id)
                        ? (4 == this.game_task_info.id && (i.GlobalParams.ChangeGameMode = 0),
                          this.uiManager.showPopup("MatchViewUI"))
                        : -1 != [5, 6].indexOf(this.game_task_info.id)
                        ? this.uiManager.showPopup("ShopViewUI", function (e) {
                              e.getComponent(c.default).showShopTypeInfo("shop_talent_btn");
                          })
                        : 7 == this.game_task_info.id
                        ? this.uiManager.showPopup("DowerViewUI")
                        : 10 == this.game_task_info.id &&
                          this.uiManager.showPopup("GetZsViewUI", function (e) {
                              e.getComponent(d.default).showPopupInfoView(0);
                          });
            }),
            __decorate([u(cc.Label)], t.prototype, "active_num", void 0),
            __decorate([u(cc.Label)], t.prototype, "task_name", void 0),
            __decorate([u(cc.Label)], t.prototype, "task_info", void 0),
            __decorate([u(cc.Node)], t.prototype, "task_schedule_bar", void 0),
            __decorate([u(cc.Label)], t.prototype, "schedule_num", void 0),
            __decorate([u(cc.Node)], t.prototype, "go_btn_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "get_award_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "task_award_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "get_over_node", void 0),
            __decorate([_], t)
        );
    })(n.default);
o.default = p;
